#pragma once
#include "Triangle.h"

class CMesh : public CPrimitive
{

public:
	int					m_Triangles;

private:
	CTriangle			*m_Tris;

public:
	CMesh() : m_Tris(new CTriangle[1]), m_Triangles(1) { m_Tris[0] = CTriangle(); m_Color = new CLightIntensity(0.9f, 0.9f, 0.9f); m_IsMesh = true; }
	CMesh(const CMesh & _mesh) { m_Triangles = _mesh.m_Triangles; m_Tris = _mesh.m_Tris; m_Color = new CLightIntensity(0.9f, 0.9f, 0.9f); m_IsMesh = true; }
	CMesh(CTriangle *_tris, int _lngt) : m_Tris(new CTriangle[_lngt]), m_Triangles(_lngt) { for (int i = 0; i < _lngt; i++) m_Tris[i] = _tris[i]; m_Color = new CLightIntensity(0.9f, 0.9f, 0.9f); m_IsMesh = true; }
	~CMesh();

	CTriangle *GetTriangles() { return m_Tris; }
	void SetTriangles(CTriangle *_tris, int _lngt) { if (m_Tris) delete m_Tris; m_Tris = _tris; m_Triangles = _lngt; }
	int	Intersect(CRay&, IsectData&);
	int	Intersect(CRay&, IsectData&, CVector&);
};